﻿using Styx.Common;
using Styx.TreeSharp;
using Action = Styx.TreeSharp.Action;

namespace TuanHA_Paladin
{
    public partial class Classname
    {
        #region Retribution Rotation

        private Composite RetributionRotation()
        {
            return new PrioritySelector(
                new Action(delegate
                               {
                                   //target the lowest threat unit
                                   if (THSettings.Instance.SAutoTarget && Me.CurrentTarget != null &&
                                       Me.CurrentTarget.IsValid && Me.CurrentTarget.Distance > 30 && GetUnitNear() &&
                                       _unitNear.IsValid && Me.CurrentTarget != _unitNear)
                                   {
                                       _unitNear.Target();
                                       Logging.Write(LogLevel.Diagnostic, "Switch to Near Target");
                                   }

                                   //target the lowest threat unit
                                   if (THSettings.Instance.SAutoTarget && Me.CurrentTarget == null &&
                                       GetUnitNear() &&
                                       _unitNear.IsValid)
                                   {
                                       _unitNear.Target();
                                       Logging.Write(LogLevel.Diagnostic, "Target  Near Unit");
                                   }

                                   //Hold dps on Dungeon 
                                   if ((Me.CurrentMap.IsDungeon ||
                                        Me.CurrentMap.IsRaid) &&
                                       !Me.Combat &&
                                       Me.CurrentTarget != null &&
                                       IsEnemy(Me.CurrentTarget) &&
                                       !Me.CurrentTarget.IsTargetingMyPartyMember &&
                                       !Me.CurrentTarget.IsTargetingMyRaidMember &&
                                       !Me.CurrentTarget.IsTargetingMeOrPet)
                                   {
                                       return RunStatus.Success;
                                   }

                                   ////Hold dps on Dungeon 
                                   //if (Me.CurrentMap.IsDungeon &&
                                   //    Me.CurrentTarget != null &&
                                   //    !Me.CurrentTarget.IsTargetingMyPartyMember)
                                   //{
                                   //    return RunStatus.Success;
                                   //}

                                   ////Hold dps on Dungeon or Raid
                                   //if (Me.CurrentMap.IsRaid &&
                                   //    Me.CurrentTarget != null &&
                                   //    Me.CurrentTarget.IsTargetingMyRaidMember)
                                   //{
                                   //    return RunStatus.Success;
                                   //}

                                   return RunStatus.Failure;
                               }),
                //But first, facing target
                new Decorator(
                    ret =>
                    THSettings.Instance.SFace &&
                    ValidUnit(Me.CurrentTarget) &&
                    IsEnemy(Me.CurrentTarget) &&
                    !Me.IsFacing(Me.CurrentTarget) &&
                    Me.CurrentTarget.InLineOfSpellSight &&
                    !IsOverrideModeOn,
                    new Action(delegate
                                   {
                                       Me.CurrentTarget.Face();
                                       return RunStatus.Failure;
                                   })
                    ),
                BubbleFlashofLightRet(),
                //Starting the movement right here
                //MovementMoveBehind(ret => Me.CurrentTarget),
                MovementMoveToMelee(ret => Me.CurrentTarget),
                MovementMoveStop(ret => Me.CurrentTarget, 3),
                //DPS Rotation Here
                SetAutoAttack(),
                LayonHandsMe(),
                Rebuke(),
                ArcaneTorrent(),
                LayonHandsFriend(),
                AvengingWrathBurstRet(),
                HolyAvengerBurstRet(),
                DivineProtectionMe(),
                ReckoningComp(),
                DevotionAura(),
                UseHealthstone(),
                UseBattleStandard(),
                HammerofJustice(),
                BlindingLight(),
                WarStomp(),
                HammerofJusticeBurstRet(),
                DivineShieldMe(),
                HandofProtectionMe(),
                HandofProtectionFriendRemoveCC(),
                HandofProtectionFriend(),
                CrowdControlSurviveComp(),
                GuardianofAncientKingsAttack(),
                HandofFreedomMe(),
                EmancipateMe(),
                SealofTruth(),
                SealofTruthfromRighteousness(),
                SealofRighteousness(),
                FlashofLightSelflessHealer(),
                InquisitionMe(),
                JudgementRangeRetPvP(),
                JudgementRangeRetPvE(),
                LightHammerHeal(),
                HolyPrismHeal(),
                ExecutionSentenceHeal(),
                WordofGloryMeRet(),
                DivineStorm5HolyPower(),
                TemplarsVerdict5HolyPower(),
                ExecutionSentenceRet(),
                LightHammerRet(),
                HammeroftheRighteousRetPvE4PlusUnit(),
                HammerofWrathCurrentTarget(),
                HammerofWrathUnitHammerofWrath(),
                AttackASAPRotationInstantComp(),
                TurnEvilASAPComp(),
                Exorcism(),
                HammeroftheRighteous(),
                HammeroftheRighteousRetArena(),
                CrusaderStrikeRet(),
                JudgementRet(),
                DivineStorm3HolyPower(),
                TemplarsVerdict3HolyPower(),
                HolyPrismRet(),
                SacredShieldMeRet(),
                WordofGloryFriendRet(),
                TurnEvilComp(),
                SacredShieldFriendRet(),
                RepentanceComp(),
                HandofSacrificeFriend(),
                HandofFreedomFriend(),
                WordofGloryMeTopUpRet(),
                FlashofLightMeRet(),
                FlashofLightFriendRet(),
                InquisitionMeTopUp(),
                FlashofLightMeTopUpRet(),
                BuffRotation(),
                RighteousFury(),
                WriteDebug("")
                );
        }

        #endregion
    }
}